package com.uuah.server.config.spring.parsers.assembly;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;

import com.uuah.server.config.spring.parsers.assembly.configuration.IPropertyConfiguration;

/**
 * This can be used inside a
 * {@link com.uuah.server.config.spring.parsers.generic.ChildDefinitionParser} - it
 * takes named properties and, instead of inserting them individually on the
 * target, it packages them as a Map and inserts that.
 */
public class AttributeMapBeanAssembler extends AbstractMapBeanAssembler {

	public AttributeMapBeanAssembler(IPropertyConfiguration beanConfig,
			BeanDefinitionBuilder bean, IPropertyConfiguration targetConfig,
			BeanDefinition target) {
		super(beanConfig, bean, targetConfig, target);
	}

	/**
	 * We override this method to insert a map instead of the definition.
	 */
	public void insertBeanInTarget(String oldName) {
		assertTargetPresent();
		insertDefinitionAsMap(oldName);
	}

}